<?php defined('IN_NWIDC') or exit('Access Invalid!');?>

<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <h3>自营店铺</h3>
      <ul class="tab-base">
        <li><a href="index.php?act=ownshop&op=list"><span>管理</span></a></li>
        <li><a href="index.php?act=ownshop&op=add"><span>新增</span></a></li>
        <li><a href="javascript:;" class="current"><span>编辑</span></a></li>
      </ul>
    </div>
  </div>
  <div class="fixed-empty"></div>
  <table class="table tb-type2" id="prompt">
    <tbody>
      <tr class="space odd">
        <th colspan="12"><div class="title">
            <h5><?php echo $lang['nc_prompts'];?></h5>
            <span class="arrow"></span></div>
        </th>
      </tr>
      <tr>
        <td><ul>
            <li>可以修改自营店铺的店铺名称以及店铺状态是否为开启状态</li>
            <li>可以修改自营店铺的店主商家中心登录账号</li>
            <li>如需修改店主登录密码，请到会员管理中，搜索“店主账号”相应的会员并编辑</li>
            <li>已绑定所有类目的自营店，如果将“绑定所有类目”设置为“否”，则会下架其所有商品，请谨慎操作！</li>
          </ul></td>
      </tr>
    </tbody>
  </table>
  <div class="homepage-focus" nctype="editStoreContent">
    <ul class="tab-menu">
      <li class="current">店铺信息</li>
      <li>汇聚分账</li>
    </ul>
    <form id="store_form" method="post">
      <input type="hidden" name="form_submit" value="ok" />
      <input type="hidden" name="store_id" value="<?php echo $output['store_array']['store_id']; ?>" />
      <table class="table tb-type2">
        <tbody>
        <tr>
          <td colspan="2" class="required"><label class="validation" for="store_name">店铺名称:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="<?php echo $output['store_array']['store_name'];?>" id="store_name" name="store_name" class="txt" /></td>
          <td class="vatop tips"></td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label for="store_name">开店时间:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><?php echo ($t = $output['store_array']['store_time'])?@date('Y-m-d',$t):'';?></td>
          <td class="vatop tips"></td>
        </tr>
        <tr class="noborder">
          <td colspan="2" class="required"><label>店主账号:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><?php echo $output['store_array']['member_name'];?></td>
          <td class="vatop tips"></td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label class="validation" for="seller_name">店主卖家账号:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><input type="text" value="<?php echo $output['store_array']['seller_name'];?>" id="seller_name" name="seller_name" class="txt" /></td>
          <td class="vatop tips">用于登录商家中心，可与店主账号不同</td>
        </tr>
        </tbody>
        <tbody>
        <tr>
          <td colspan="2" class="required"><label>
              <label for="bind_all_gc">绑定所有类目:</label>
            </label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform onoff">
            <label for="bind_all_gc1" class="cb-enable <?php if ($output['store_array']['bind_all_gc'] == '1'){ ?>selected<?php } ?>" ><span>是</span></label>
            <label for="bind_all_gc0" class="cb-disable <?php if($output['store_array']['bind_all_gc'] == '0'){ ?>selected<?php } ?>" ><span>否</span></label>
            <input id="bind_all_gc1" name="bind_all_gc" <?php if($output['store_array']['bind_all_gc'] == '1'){ ?>checked="checked"<?php } ?> value="1" type="radio">
            <input id="bind_all_gc0" name="bind_all_gc" <?php if($output['store_array']['bind_all_gc'] == '0'){ ?>checked="checked"<?php } ?> value="0" type="radio">
          </td>
          <td class="vatop tips"></td>
        </tr>
        </tbody>

        <tbody>
        <tr>
          <td colspan="2" class="required"><label>
              <label for="state">状态:</label>
            </label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform onoff"><label for="store_state1" class="cb-enable <?php if($output['store_array']['store_state'] == '1'){ ?>selected<?php } ?>" ><span><?php echo $lang['open'];?></span></label>
            <label for="store_state0" class="cb-disable <?php if($output['store_array']['store_state'] == '0'){ ?>selected<?php } ?>" ><span><?php echo $lang['close'];?></span></label>
            <input id="store_state1" name="store_state" <?php if($output['store_array']['store_state'] == '1'){ ?>checked="checked"<?php } ?> onclick="$('#tr_store_close_info').hide();" value="1" type="radio">
            <input id="store_state0" name="store_state" <?php if($output['store_array']['store_state'] == '0'){ ?>checked="checked"<?php } ?> onclick="$('#tr_store_close_info').show();" value="0" type="radio"></td>
          <td class="vatop tips"></td>
        </tr>
        </tbody>

        <tbody>
        <tr>
          <td colspan="2" class="required"><label>批发商:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform onoff">
            <label for="is_whole_1" class="cb-enable <?php if($output['store_array']['is_whole'] == '1'){ ?>selected<?php } ?>" ><span><?php echo $lang['member_edit_allow'];?></span></label>
            <label for="is_whole_2" class="cb-disable <?php if($output['store_array']['is_whole'] == '0'){ ?>selected<?php } ?>" ><span><?php echo $lang['member_edit_deny'];?></span></label>
            <input id="is_whole_1" name="is_whole" <?php if($output['store_array']['is_whole'] == '1'){ ?>checked="checked"<?php } ?>  value="1" type="radio">
            <input id="is_whole_2" name="is_whole" <?php if($output['store_array']['is_whole'] == '0'){ ?>checked="checked"<?php } ?> value="0" type="radio"></td>
          <td class="vatop tips"></td>
        </tr>
        </tbody>

          <tbody>
          <tr>
              <td colspan="2" class="required"><label>个人店铺:</label></td>
          </tr>
          <tr class="noborder">
              <td class="vatop rowform onoff">
                  <label for="is_personal_1" class="cb-enable <?php if($output['store_array']['is_personal'] == '1'){ ?>selected<?php } ?>" ><span><?php echo $lang['member_edit_allow'];?></span></label>
                  <label for="is_personal_2" class="cb-disable <?php if($output['store_array']['is_personal'] == '0'){ ?>selected<?php } ?>" ><span><?php echo $lang['member_edit_deny'];?></span></label>
                  <input id="is_personal_1" name="is_personal" <?php if($output['store_array']['is_personal'] == '1'){ ?>checked="checked"<?php } ?>  value="1" type="radio">
                  <input id="is_personal_2" name="is_personal" <?php if($output['store_array']['is_personal'] == '0'){ ?>checked="checked"<?php } ?> value="0" type="radio"></td>
              <td class="vatop tips"></td>
          </tr>
          </tbody>


        <tbody>
        <tr>
          <td colspan="2" class="required"><label>
              <label for="state">海关备案号:</label>
            </label>
          </td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform">
            <input type="text" id="ebcCode" name="ebcCode" class="txt valid" value='<?php echo $output['store_array']['ebcCode']?>'>
          </td>
          <td class="vatop tips"></td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label>
              <label for="state">企业中文名称:</label>
            </label>
          </td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform">
            <input type="text"id="ebcName" name="ebcName" class="txt valid" value='<?php echo $output['store_array']['ebcCode']?>'>
          </td>
          <td class="vatop tips"></td>
        </tr>
        <tr>
          <td colspan="2" class="required"><label>
              <label for="state">使用导入订单和通联支付API:</label>
            </label></td>
        </tr>

        <tr class="noborder">
          <td class="vatop rowform onoff">
            <label for="useIETAPI1" class="cb-enable <?php if($output['store_array']['useIETAPI'] == '1'){ ?>selected<?php } ?>" ><span><?php echo $lang['open'];?></span></label>
            <label for="useIETAPI0" class="cb-disable <?php if($output['store_array']['useIETAPI'] == '0'){ ?>selected<?php } ?>" ><span><?php echo $lang['close'];?></span></label>
            <input id="useIETAPI1" name="useIETAPI" <?php if($output['store_array']['useIETAPI'] == '1'){ ?>checked="checked"<?php } ?> value="1" type="radio">
            <input id="useIETAPI0" name="useIETAPI" <?php if($output['store_array']['useIETAPI'] == '0'){ ?>checked="checked"<?php } ?> value="0" type="radio"></td>
          <td class="vatop tips"></td>
        </tr>
        </tbody>
        <tbody id="tr_store_close_info">
        <tr >
          <td colspan="2" class="required"><label for="store_close_info">关闭原因:</label></td>
        </tr>
        <tr class="noborder">
          <td class="vatop rowform"><textarea name="store_close_info" rows="6" class="tarea" id="store_close_info"><?php echo $output['store_array']['store_close_info'];?></textarea></td>
          <td class="vatop tips"></td>
        </tr>
        </tbody>
        <tfoot>
        <tr class="tfoot">
          <td colspan="15"><a href="JavaScript:void(0);" class="btn" id="submitBtn"><span><?php echo $lang['nc_submit'];?></span></a></td>
        </tr>
        </tfoot>
      </table>
    </form>

    <form action="" method="post" id="join_pay_form" style="display:none;">
      <input type="hidden" name="store_id" value="<?php echo $output['store_array']['store_id']; ?>" />
      <table border="0" cellpadding="0" cellspacing="0" class="store-joinin">
        <thead>
        <tr>
          <th colspan="20">结算账号信息：</th>
        </tr>
        </thead>
        <tbody>
        <tr><th class="w150">分账方登录名：</th> <td><input type="text" class="txt w300" name="jp_login_name" value="<?php echo $output['joinPayAlloc']['jp_login_name'];?>"></td></tr>
        <tr><th class="w150">分账方名称：</th> <td><input type="text" class="txt w300" name="jp_alt_mch_name" value="<?php echo $output['joinPayAlloc']['jp_alt_mch_name'];?>"></td></tr>
        <tr><th class="w150">分账方账号：</th> <td><input type="text" class="txt w300" disabled value="<?php echo $output['joinPayAlloc']['jp_alt_mch_no'];?>"> 添加成功后显示！</td></tr>
        <!--        <tr><th class="w150">分账方商户简称：</th> <td><input type="text" class="txt w300" name="jp_alt_mch_short_name" value="--><?php //echo $output['joinPayAlloc']['jp_alt_mch_short_name'];?><!--"></td></tr>-->
        <tr><th class="w150">分账方商户类型：</th> <td><input type="text" class="txt w300" name="jp_alt_merchant_type" value="<?php echo $output['joinPayAlloc']['jp_alt_merchant_type'];?>">&nbsp;值为：10:个人，11：个体工商户，12：企业 Integer</td></tr>
        <tr><th class="w150">业务联系人姓名：</th> <td><input type="text" class="txt w300" name="jp_busi_contact_name" value="<?php echo $output['joinPayAlloc']['jp_busi_contact_name'];?>"></td></tr>
        <tr><th class="w150">业务联系人手机：</th> <td><input type="text" class="txt w300" name="jp_busi_contact_mobile_no" value="<?php echo $output['joinPayAlloc']['jp_busi_contact_mobile_no'];?>"></td></tr>
        <tr><th class="w150">法人手机号：</th> <td><input type="text" class="txt w300" name="jp_phone_no" value="<?php echo $output['joinPayAlloc']['jp_phone_no'];?>"></td></tr>
        <!--        <tr><th class="w150">经营范围：</th> <td><input type="text" class="txt w300" name="jp_manage_scope" value="--><?php //echo $output['joinPayAlloc']['jp_manage_scope'];?><!--"></td></tr>-->
        <!--        <tr><th class="w150">经营地址：</th> <td><input type="text" class="txt w300" name="jp_manage_addr" value="--><?php //echo $output['joinPayAlloc']['jp_manage_addr'];?><!--"></td></tr>-->
        <tr><th class="w150">法人姓名：</th> <td><input type="text" class="txt w300" name="jp_legal_person" value="<?php echo $output['joinPayAlloc']['jp_legal_person'];?>"></td></tr>
        <tr><th class="w150">身份证号：</th> <td><input type="text" class="txt w300" name="jp_id_card_no" value="<?php echo $output['joinPayAlloc']['jp_id_card_no'];?>"></td></tr>
        <!--        <tr><th class="w150">身份证有效期：</th> <td><input type="text" class="txt w300" name="jp_id_card_expiry" value="--><?php //echo $output['joinPayAlloc']['jp_id_card_expiry'];?><!--"></td></tr>-->
        <!--        <tr><th class="w150">营业执照编号：</th> <td><input type="text" class="txt w300" name="jp_license_no" value="--><?php //echo $output['joinPayAlloc']['jp_license_no'];?><!--"></td></tr>-->
        <!--        <tr><th class="w150">营业执照有效期：</th> <td><input type="text" class="txt w300" name="jp_license_expiry" value="--><?php //echo $output['joinPayAlloc']['jp_license_expiry'];?><!--"></td></tr>-->
        <tr><th class="w150">结算方式：</th> <td><input type="text" class="txt w300" name="jp_sett_mode" value="<?php echo $output['joinPayAlloc']['jp_sett_mode'];?>">&nbsp;值为： 1 由汇聚自动结算;2 由商户平台手工结算（结算接口）Integer</td></tr>
        <tr><th class="w150">结算周期类型：</th> <td><input type="text" class="txt w300" name="jp_sett_date_type" value="<?php echo $output['joinPayAlloc']['jp_sett_date_type'];?>">&nbsp;值为：1 工作日，2 自然日，3 月结日 Integer</td></tr>
        <tr><th class="w150">结算周期：</th> <td><input type="text" class="txt w300" name="jp_risk_day" value="<?php echo $output['joinPayAlloc']['jp_risk_day'];?>">&nbsp;值为：1-28 的自然日 Integer</td></tr>
        <tr><th class="w150">账户类型：</th> <td><input type="text" class="txt w300" name="jp_bank_account_type" value="<?php echo $output['joinPayAlloc']['jp_bank_account_type'];?>">账户类型 值为：1 借记卡，4 对公账户 Integer 是 是</td></tr>
        <tr><th class="w150">银行账户名称：</th> <td><input type="text" class="txt w300" name="jp_bank_account_name" value="<?php echo $output['joinPayAlloc']['jp_bank_account_name'];?>"></td></tr>
        <tr><th class="w150">银行账号：</th> <td><input type="text" class="txt w300" name="jp_bank_account_no" value="<?php echo $output['joinPayAlloc']['jp_bank_account_no'];?>"></td></tr>
        <!--        <tr><th class="w150">联行号：</th> <td><input type="text" class="txt w300" name="jp_bank_channel_no" value="--><?php //echo $output['joinPayAlloc']['jp_bank_channel_no'];?><!--"></td></tr>-->
        </tbody>
      </table>
      <div><a id="btn_join_pay" class="btn" href="JavaScript:void(0);"><span><?php echo $lang['nc_submit'];?></span></a></div>
    </form>
  </div>
</div>
<script src="/data/resource/layer/layer.js"></script>
<script type="text/javascript">
$(function(){

    $('input[name=store_state][value=<?php echo $output['store_array']['store_state'];?>]').trigger('click');

    //按钮先执行验证再提交表单
    $("#submitBtn").click(function(){
        if($("#store_form").valid()){
            $("#store_form").submit();
        }
    });

    $('#store_form').validate({
        errorPlacement: function(error, element){
            error.appendTo(element.parentsUntil('tr').parent().prev().find('td:first'));
        },
        rules : {
            store_name: {
                required : true,
                remote : '<?php echo urlAdmin('ownshop', 'ckeck_store_name', array('store_id' => $output['store_array']['store_id']))?>'
            },
            seller_name: {
                required : true,
                remote   : {
                    url : 'index.php?act=ownshop&op=check_seller_name&id=<?php echo $output['store_array']['store_id']; ?>',
                    type: 'get',
                    data:{
                        seller_name : function(){
                            return $('#seller_name').val();
                        }
                    }
                }
            }
        },
        messages : {
            store_name: {
                required: '请输入店铺名称',
                remote : '店铺名称已存在'
            },
            seller_name: {
                required : '请输入店主卖家账号',
                remote   : '此名称已被其它店铺占用，请重新输入'
            }
        }
    });

    $("#btn_join_pay").click(function(){
      $.post('<?php echo WEB_DOMAIN;?>/pay/joinPayAlloc/index2', $("#join_pay_form").serialize(),function (msg) {
        if(msg && msg.state == true){
          layer.msg("受理成功");
        }else{
          layer.msg("受理失败"+JSON.stringify(msg.data.data));
        }

      },'json');
    });
    $('div[nctype="editStoreContent"] > ul').find('li').click(function(){
      $(this).addClass('current').siblings().removeClass('current');
      var _index = $(this).index();
      var _form = $('div[nctype="editStoreContent"]').find('form');
      _form.hide();
      _form.eq(_index).show();
    });

});
</script>
